package cn.maiyar.dingding.config;

import cn.maiyar.dingding.DingDingProperties;
import cn.maiyar.dingding.feign.IDingDingClient;
import cn.maiyar.dingding.service.DingDingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * DingDing配置文件
 *
 * @author c.c
 **/
@Slf4j
@EnableConfigurationProperties(DingDingProperties.class)
@ConditionalOnProperty(prefix = "meta.dingding", name = "enabled", havingValue = "true")
public class DingConfig {

    @Bean
    public IDingDingClient dingdingHttpClient(DingDingProperties dingDingProperties) {
        log.debug("初始化 IDingDingClient!");
        return new DingDingService(dingDingProperties);
    }
}
